<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-select v-model="dataForm.payType"  placeholder="请选择支付类型">
        <el-option
          v-for="item in payTypeOptions"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
      </el-form-item>
      <el-form-item>
        <el-date-picker
          v-model="dataForm.startTime"
          type="date"
          format="yyyy 年 MM 月 dd 日"
          value-format="yyyy-MM-dd"
          placeholder="选择开始日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-date-picker
          v-model="dataForm.endTime"
          type="date"
          format="yyyy 年 MM 月 dd 日"
          value-format="yyyy-MM-dd"
          placeholder="选择结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
        <el-button @click="reset()">重置</el-button>
        <!-- <el-button v-if="isAuth(':edulesson:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
        <el-button v-if="isAuth(':edulesson:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button> -->
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">
      <el-table-column
        type="selection"
        header-align="center"
        align="center"
        width="50">
      </el-table-column>
      <el-table-column
        type="index"
        header-align="center"
        align="center"
        width="80"
        label="序号">
      </el-table-column>
      <el-table-column
        prop="totalMoney"
        header-align="center"
        align="center"
        label="总收入">
      </el-table-column>
      
      <el-table-column
        prop="backMoney"
        header-align="center"
        align="center"
        label="退款">
      </el-table-column>
      <el-table-column
        prop="cashMoney"
        header-align="center"
        align="center"
        label="现金">
      </el-table-column>
      <el-table-column
        prop="wxMoney"
        header-align="center"
        align="center"
        label="微信">
      </el-table-column>
      <el-table-column
        prop="zfbMoney"
        header-align="center"
        align="center"
        label="支付宝">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        dataForm: {
          payType: '',
          startTime: '',
          endTime: '',
        },
        dataList: [],
        payTypeOptions: [
          {
            value: 1,
            label: '微信'
          }, {
            value: 2,
            label: '支付宝'
          },
          {
            value: 3,
            label: '现金'
          }
          ],
        classId: '',
        startTime: '',
        endTime: '',
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false
      }
    },
    activated () {
      this.getDataList();
      // this.getClassList();
    },
    methods: {
      selectionChangeHandle() {

      },
      reset(){
        this.dataForm = {
          payType: '',
          startTime: '',
          endTime: '',
        }
        this.getDataList();
      },
      // 统计分析
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/sys/stat/order'),
          method: 'post',
          data: this.$http.adornData({
            'payType': this.dataForm.payType,
            'startTime': this.dataForm.startTime,
            'endTime': this.dataForm.endTime
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
          } else {
            this.dataList = []
          }
          this.dataListLoading = false
        })
      },
      // getClassList() {
      //   this.dataListLoading = true
      //   this.$http({
      //     url: this.$http.adornUrl('/sys/educlass/list'),
      //     method: 'get',
      //     params: this.$http.adornParams({
      //       'page': 1,
      //       'limit': 100,
      //       'isDeleted':0
      //     })
      //   }).then(({data}) => {
      //     if (data && data.code === 0) {
      //       let dataList = data.page.list
      //       let classOptions = [];
      //       dataList.forEach((item) => {
      //         let obj = {};
      //         obj.value = item.id;
      //         obj.label = item.name;
      //         classOptions.push(obj);

      //       })
      //       this.classOptions = classOptions;
      //     }
      //     this.dataListLoading = false
      //   })
      // }
    }
  }
</script>
